package com.czl.module_storehouse.mvp.model;

import android.util.Log;

import com.czl.base.BuildConfig;
import com.czl.base.config.AppConstants;
import com.czl.base.data.net.RetrofitClient;
import com.czl.base.util.SpHelper;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_base.mvp.model.BaseModel;
import com.czl.module_service.system.Constants;
import com.czl.module_storehouse.api.ApiService;
import com.czl.module_storehouse.bean.ShiftBean;
import com.google.gson.Gson;

import org.json.JSONObject;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.functions.Function;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * @author by xubin,
 * @date on 2022/2/14.
 * PS: Not easy to write code, please indicate.
 */
public class ShiftModel extends BasicDataModel {

    public Observable<HttpResponse<ShiftBean>> addShiftInfo(ShiftBean bean) {
        bean.setShiftPersonId(getUserId());
        bean.setShiftPersonName(getTName());
        bean.setStorehouseId(getStorehouseId());
        Gson gson = new Gson();
        String json = gson.toJson(bean);
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "ShiftBean :" + json);
        }
        MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
        return RetrofitClient.getInstance().create(ApiService.class).addShiftInfo(RequestBody.create(mediaType, json));
    }
}
